package designPattern.action11.Visitor.c24t2;

import java.util.ArrayList;
import java.util.Iterator;

import designPattern.action11.Visitor.c24t2.concrete.visitor.Company;
import designPattern.action11.Visitor.c24t2.concrete.student.GraduateStudent;
import designPattern.action11.Visitor.c24t2.concrete.student.Undergraduate;
import designPattern.action11.Visitor.c24t2.sketch.Student;
import designPattern.action11.Visitor.c24t2.sketch.Visitor;
/*
访问者模式
本例子：
单个访问者


 */
public class Application {
    public static void main(String args[]) {
        Visitor visitor = new Company();
        ArrayList<Student> studentList = new ArrayList<Student>();
        Student student = null;
        studentList.add(student = new Undergraduate("大学生：张三", 67, 88));//数学太差，不录音
        studentList.add(student = new Undergraduate("大学生：李四", 90, 98));//录用
        studentList.add(student = new Undergraduate("大学生：将粼粼", 85, 92));//录用

        studentList.add(student = new GraduateStudent("研究生：刘名", 88, 70, 87));//英语太差，不录音
        studentList.add(student = new GraduateStudent("研究生：郝人", 90, 95, 82));//录用
        Iterator<Student> iter = studentList.iterator();
        while (iter.hasNext()) {
            Student stu = iter.next();
            stu.accept(visitor);
        }
    }
} 
